nexus\api\rtapi/
data.rs

1use crate::data_link::{get_resource, read_resource};
2use bitfields::bitfield;
3use std::ffi::c_char;
4
5#[derive(Debug, Clone)]
6#[repr(C)]
7pub struct RealTimeData {
8    /// Game build number.
9    pub game_build: u32,
10
11    /// Current game state.
12    pub game_state: u32,
13
14    /// Language setting in game client.
15    pub language: u32,
16
17    /// Tyrian time of day.
18    pub time_of_day: u32,
19
20    /// Map id of current map.
21    pub map_id: u32,
22
23    /// Map type of current map.
24    pub map_type: u32,
25
26    /// IP address of current server.
27    pub ip_address: [u8; 4],
28
29    /// Location of cursor in the game world as ingame coordinates.
30    pub cursor: [f32; 3],
31
32    /// Locations of squad markers in the game world as ingame coordinates.
33    pub squad_markers: [[f32; 3]; 8],
34
35    /// Type of current group.
36    pub group_type: u32,
37
38    /// Number of members in current group.
39    pub group_member_count: u32,
40
41    /// Reserved for future use.
42    _reserved2: u32,
43
44    /// Reserved for future use.
45    _reserved1: u32,
46
47    /// Account name of current player.
48    pub account_name: [c_char; 140],
49
50    /// Character name of current player.
51    pub character_name: [c_char; 140],
52
53    /// Current position of character.
54    pub character_position: [f32; 3],
55
56    /// Current facing direction of character.
57    pub character_facing: [f32; 3],
58
59    /// Profession of character.
60    pub profession: u32,
61
62    /// Current 3rd specialization of character.
63    pub elite_specialization: u32,
64
65    /// Index of the mount, if applicable.
66    pub mount_index: u32,
67
68    /// Current state of character.
69    pub character_state: u32,
70
71    /// Camera position in the game world.
72    pub camera_position: [f32; 3],
73
74    /// Camera facing direction.
75    pub camera_facing: [f32; 3],
76
77    /// Camera field of view.
78    pub camera_fov: f32,
79
80    /// Whether action camera is enabled.
81    pub is_action_camera: IsActionCam,
82}
83
84impl RealTimeData {
85    /// Signature of the RealTime API addon.
86    pub const SIG: i32 = 0x2501A02C;
87
88    /// RealTime API data link identifier.
89    pub const LINK: &str = "RTAPI";
90
91    #[inline]
92    pub fn get_ptr() -> *const Self {
93        get_resource(Self::LINK)
94    }
95
96    #[inline]
97    pub fn read() -> Option<Self> {
98        unsafe { read_resource(Self::LINK) }
99    }
100}
101
102// This only has a single bit, so maybe just using u32 is enough, since this is only read I assume
103#[bitfield(u32)]
104#[derive(Copy, Clone, PartialEq, Eq)]
105#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
106pub struct IsActionCam {
107    pub is_action_camera: bool,
108
109    #[bits(31)]
110    _padding: u32,
111}